home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** $VER: Build_Index.ieb 1.3, IE Arexx script ** Image Engineer Batch Processing script ** Copyright © by Patrik M Nydensten ** 2/2 1997 Stockholm/Sweden ** ** Outputs only one single image containing thumbnail images ** of all selected PRIMARY images. */ options results signal on error parse arg input command input = upper(strip(input)) address 'IMAGEENGINEER' select /* Required batch script commands */ when input = 'INFO' then return get_info() when input = 'CONFIG' then return get_config(command) when input = 'PROCESS' then return process_image(command) otherwise do 'REQUEST' '"Failure in call to batch script!"' '" Quit "' return '<ERROR>' end end exit 0 /* Required "Get_info" procedure ------------------------------------ */ /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files */ get_info: back = 'OK F' return back /* Required "Get_config" procedure ---------------------------------- */ get_config: parse arg command 'IE_TO_FRONT' /* Unchanged config, only picked for first image */ if command = '' then do 'FORM "Build Index" " OK | Cancel "', ' INTEGER,"Number of horiz. thumbnails",1,64,10,SLIDER', ' INTEGER,"Thumbnail X size",16,320,64,SLIDER', ' INTEGER,"Thumbnail Y size",16,256,64,SLIDER', ' STRING,"Output base name","Output"', ' CHECKBOX,"Keep image aspect in thumbnails?",1' parse var result ok Thumb Xsize Ysize '"'Base'"' Aspect . if ok = 0 then return '<ERROR>' end else do 'REQUEST' '"The Build_Index.ieb does only have'd2c(10)||, 'settings for the first image."' '" OK "' Thumb = 'none' Xsize = 'none' Ysize = 'none' Base = 'none' Aspect = 'none' end Base = translate(Base,'ª',' ') back = '#'Thumb '#'Xsize '#'Ysize '#'Base '#'Aspect return back /* Required "Process_image" procedure ------------------------------- */ process_image: parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' '"'frame':'num_frames'"' parse var options '#'Thumb '#'Xsize '#'Ysize '#'Base '#'Aspect . 'OPEN' '"'src_image'"' '24' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "' return '<ERROR>' end else LoadImage = result if Thumb > num_frames then Thumb = num_frames if frame = 1 then do /* Do only for first image */ 'BRIGHTNESS' LoadImage '-255' BlackImage = Result if (num_frames/Thumb) = trunc(num_frames/Thumb) then 'RESIZE' BlackImage (Thumb*Xsize) (Ysize*trunc(num_frames/Thumb)) else 'RESIZE' BlackImage (Thumb*Xsize) (Ysize*trunc(1+num_frames/Thumb)) BackImage = Result 'CLOSE' BlackImage end else do /* Check for last ALPHA image */ 'GET' 'ALPHA' BackImage = Result end 'PROJECT_INFO' LoadImage 'WIDTH' IW = RESULT 'PROJECT_INFO' LoadImage 'HEIGHT' IH = RESULT if (Xsize ~= IW)|(Ysize ~= IH) then do if Aspect = 1 then do /* Aspect scale */ if ((Xsize/IW) > (Ysize/IH)) then , 'SCALE' LoadImage trunc(IW*Ysize/IH) Ysize 'BEST' else 'SCALE' LoadImage Xsize trunc(IH*Xsize/IW) 'BEST' ThumbImage = Result 'CLOSE' LoadImage end else do /* Stretch scale */ 'SCALE' LoadImage Xsize Ysize 'BEST' ThumbImage = Result 'CLOSE' LoadImage end end else ThumbImage = LoadImage col = frame ; row = 1 do while (col > Thumb) col = col - Thumb row = row + 1 end 'MARK' ThumbImage 'PRIMARY' 'MARK' BackImage 'SECONDARY' 'COMPOSITE' (Xsize*(col-1)) (Ysize*(row-1)) 'MIX' 100 NewBackImage = Result 'CLOSE' BackImage 'CLOSE' ThumbImage BackImage = NewBackImage 'MARK' BackImage 'ALPHA' /* Mark as ALPHA to remember it to next load */ if frame = num_frames then do /* Only for last image */ OutputImage = BackImage Base = translate(Base,' ','ª') dst_image = get_path(dst_image)||Base'.index' if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1') 'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "' return '<ERROR>' end 'CLOSE' OutputImage end back = 'OK' return back /* Internal procedures ---------------------------------------------- */ get_path: parse arg get_path_in if lastpos('/',get_path_in) ~= 0 then get_path_back = substr(get_path_in,1,lastpos('/',get_path_in)) else if lastpos(':',get_path_in) ~= 0 then get_path_back = substr(get_path_in,1,lastpos(':',get_path_in)) else get_path_back = '' return get_path_back /*******************************************************************/ /* This is where control goes when an error code is returned by IE */ /* It puts up a message saying what happened and on which line */ /*******************************************************************/ error: if RC=5 then do IE_TO_FRONT LAST_ERROR 'REQUEST "'||RESULT||'"' end else do IE_TO_FRONT LAST_ERROR 'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!' end return '<ERROR>'